libelf: treat phdr and shdr similarly
authorJan Beulich <jbeulich@suse.com>
Wed, 7 Dec 2016 12:53:50 +0000 (13:53 +0100)
committerJan Beulich <jbeulich@suse.com>
Wed, 7 Dec 2016 12:53:50 +0000 (13:53 +0100)
commita01b6d464f05dadf28bfd38612283bd1848f1350
treebf149f73f787dee35c7729376c282a3b3e3b386d
parent397f64d126cefb1a93e8fc469c0431e9256226cf
libelf: treat phdr and shdr similarly

Just like elf_shdr_count(), elf_phdr_count() better bounds checks the
value.

Add table entry size checks to elf_init().

Also both program and section headers are optional, and hence their
checking better is done conditionally only when any such headers are
present.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
xen/common/libelf/libelf-loader.c
xen/common/libelf/libelf-tools.c